package com.gitee.haioa;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static final List<String> apps = new ArrayList<>();

    public static final List<String> apps1 = new ArrayList<>();

    public static void main(String[] args) {
        //清理旧文件数据
        System.out.println("=================================清理旧文件数据中=================================");
        String deskTopPath = LinuxShell.getDeskTopPath() + "/生成脚本";
        File file = new File(deskTopPath);
        if (file.exists() && file.isDirectory()){
            System.out.println("=========正在清理"+file.getName()+"中===========");
            LinuxShell.deleteFolder(deskTopPath);
        }
        System.out.println("=================================清理旧文件数据完成=================================");
        System.out.println("=================================请输入linux项目部署的目录，例如：/opt/zhsw/backend =================================");
        System.out.print("请您输入：");
        Scanner scanner = new Scanner(System.in);
        String path = scanner.next();
        LinuxShell.PARENT_PATH = path;
        System.out.println("=================================Linux脚本生成中=================================");
        apps.add("/common-flow/comm-flow-1.0.0.jar");
        apps.add("/dispatch-manage/dispatch-manage-1.0.0.jar");
        apps.add("/flow_project/flow_project-1.0.0.jar");
        apps.add("/hnls-admin/hnls-admin-service-1.0.0.jar");
        apps.add("/hnls-dc/hnls-dc-1.0.0.jar");
        apps.add("/hnls-gis/hnls-gis-1.0.0.jar");
        apps.add("/hnls-gps/hnls-gps-boot-1.0.0.jar");
        apps.add("/hnls-mis/hnls-mis-boot-1.0.0.jar");
        apps.add("/hnls-scada/hnls-scada-1.0.0.jar");
        apps.add("/water-quality/water-quality-1.0.0.jar");
        apps.add("/auth/tofly-auth-1.0.0.jar");
        apps.add("/gateway/tofly-getway-1.0.0.jar");
        for (String app : apps) {
            LinuxShell.createShellFile(app);
        }
        //创建linux一键运行脚本
        LinuxShell.createShellRunFile();
        System.out.println("=================================Linux脚本生成结束=================================\n");

        System.out.println("=================================windows脚本生成中=================================");
        //TODO windows脚本杀死进程需要自己手动修改端口号
//        apps1.add("10311:/common-flow/comm-flow-1.0.0.jar");
//        apps1.add("9002:/dispatch-manage/dispatch-manage-1.0.0.jar");
//        apps1.add("9003:/flow_project/flow_project-1.0.0.jar");
//        apps1.add("9004:/hnls-admin/hnls-admin-service-1.0.0.jar");
//        apps1.add("9005:/hnls-dc/hnls-dc-1.0.0.jar");
//        apps1.add("10102:/hnls-gis/hnls-gis-1.0.0.jar");
//        apps1.add("10103:/hnls-gps/hnls-gps-boot-1.0.0.jar");
//        apps1.add("9008:/hnls-mis/hnls-mis-boot-1.0.0.jar");
//        apps1.add("9009:/hnls-scada/hnls-scada-1.0.0.jar");
//        apps1.add("9010:/water-quality/water-quality-1.0.0.jar");
//        apps1.add("9055:/auth/tofly-auth-1.0.0.jar");
//        apps1.add("9066:/gateway/tofly-getway-1.0.0.jar");
//        for (String app : apps1) {
//            WinShell.createShellFile(app);
//        }
        System.out.println("=================================windows脚本生成结束=================================");
    }
}